
public class string10 {

	public static void main(String[] args)throws Exception
	{
		String str = "   dfkjlsk     ldkjfk dlk      jl    lk ";
		StringBuilder strb = new StringBuilder(str);
		while(strb.charAt(0) == ' ') strb.deleteCharAt(0);
		while(strb.charAt(strb.length() - 1) == ' ') strb.deleteCharAt(strb.length() - 1);
		for(int i = 0; i < strb.length(); i++)
			if(strb.charAt(i) == ' ')
				while(strb.charAt(i + 1) == ' ') strb.deleteCharAt(i + 1);
		System.out.println(strb.toString());

	}

}
